package com.sasis.webapp.task;

import javax.servlet.ServletContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sasis.service.FunctionService;
import com.sasis.service.HandleTypeService;

public class InitializeFunctionsTask implements StartupTask {
	
	private static final Log log = LogFactory.getLog(InitializeFunctionsTask.class);
	
	private FunctionService functionService;
	
	private HandleTypeService handleTypeService;
	
	public void setFunctionService(FunctionService functionService) {
		this.functionService = functionService;
	}

	public void setHandleTypeService(HandleTypeService handleTypeService) {
		this.handleTypeService = handleTypeService;
	}
	
	public void doTask(ServletContext context) {
		try {
			log.debug("InitialFunctionsTask");
			context.setAttribute("handlesTree", functionService.getHandlesTree());
			context.setAttribute("handleTypes", handleTypeService.getHandleTypes());
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public boolean isAsynchronous() {
		return false;
	}

}
